// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init({
    env: 'cloud1-0gyq4iqkbbe4572f'
})
const db =cloud.database();

// 云函数入口函数
exports.main = async (event, context) => {
    var isColl=0;
    return new Promise((resolve, reject) => {
        db.collection('collect').where({
          _openid: event.useOpenid,
          id:event.dynamicId
        }).get().then(res => {
            console.log("测试输出")
            console.log(res.data.length)
          console.log(event.dynamicId)
          if(res.data.length==1){
             isColl=1; 
          }
          resolve({
            event,
            isColl
          });
        }).catch(err => {
            resolve({
                event,
                isColl
              });
        });
      });
}